<template>
	<view class="">
		<u-tabs :list="tblist" bar-width="110" font-size="26" active-color="#ff7200" :is-scroll="false"
			:current="current" @change="change"></u-tabs>
		<view :class="current>0?'bjs':'bj'" v-for="(item,index) in list" :key="index">
			<view class="quan">
				<view class="qian">
					<text class="danwi">￥</text>
					<text>{{item.money}}</text>
				</view>
				<view class="rightbox">
					<view class="qpq">
						{{item.name}}
					</view>
					<view class="ky">
						满{{item.full_moeny}}元可用
					</view>
					<view class="time">
						有效期至：{{item.end_time}}
					</view>
				</view>
			</view>
			<image src="http://youjialibo.wm76.mtnet.ren/upload/20210915/44d7142bc19ff642fa789537759f8a6f.png" mode="" class="gq" v-if="current==1"></image>
			<image src="http://youjialibo.wm76.mtnet.ren/upload/20210915/934d9ee5031b627b293d9e5b04cabbf6.png" mode="" class="gq" v-if="current==2"></image>
		</view>
		<u-empty text="暂无优惠券" mode="coupon" v-if="list.length==0"></u-empty>
	</view>
</template>

<script>
	import {
		getusercoupons
	} from "../../api/api/index.js"
	export default {
		data() {
			return {
				tblist: [{
					name: "未使用"
				}, {
					name: "已使用"
				}, {
					name: "已过期"
				}],
				current: 0,
				page: 0,
				limit: 10,
				list: [],
				flag: false, //是否加载完成
				type:1
			}
		},
		methods: {
			change(index) {
				this.current = index;
				this.type=index+1
				this.page=0
				this.list=[]
				this.flag=false
				this.pubilc()
			},
			pubilc(flag) {
				if (this.flag) {
					return uni.showToast({
						title:"没有更多了",
						icon:"none",
						duration:15000
					})
				}
				this.page++;
				let pass = {
					page: this.page,
					limit: this.limit,
					type:this.type
				};
				getusercoupons(pass).then((res) => {
					console.log(res.data)
					if (res.data.length < this.limit) {
						this.flag = true;
					}
					this.list = this.list.concat(res.data);
				});
			}
		},
		onShow() {
			this.page = 0;
			this.list = [];
			this.flag = false;
			this.pubilc();
		},
		onReachBottom() {
			this.pubilc()
		}
	}
</script>

<style scoped lang="scss">
	.bj {
		width: 710rpx;
		height: 185rpx;
		background-color: #fab210;
		border-radius: 20rpx;
		margin-left: 20rpx;
		margin-top: 38rpx;
		display: flex;
		align-items: center;
	}

	.quan {
		background: url(../../static/image/youhuiquan.png);
		background-size: 565rpx 159rpx;
		width: 565rpx;
		height: 159rpx;
		position: relative;

		.qian {
			display: block;
			position: absolute;
			left: 34rpx;
			top: 37rpx;
			text {
				font-family: Bebas;
				font-size: 70rpx;
				color: #ee3647;
			}
			.danwi {
				font-size: 43rpx;
			}
		}

		.rightbox {
			position: absolute;
			right: 67rpx;
			display: block;
			top: 27rpx;

			.qpq {
				font-family: MicrosoftYaHei;
				font-size: 24rpx;
				color: #ee3647;
			}

			.ky {
				width: 194rpx;
				height: 36rpx;
				background-color: #ee3647;
				border-radius: 10rpx;
				line-height: 36rpx;
				font-family: MicrosoftYaHei;
				font-size: 19rpx;
				color: #ffffff;
				padding-left: 10rpx;
				box-sizing: border-box;
				margin-top: 10rpx;
			}

			.time {
				font-family: MicrosoftYaHei;
				font-size: 18rpx;
				margin-top: 10rpx;
				color: #999999;
			}
		}
	}

	.gq {
		width: 123rpx;
		height: 93rpx;
	}


	.bjs {
		width: 710rpx;
		height: 185rpx;
		background-color: #fab210;
		border-radius: 20rpx;
		margin-left: 20rpx;
		margin-top: 38rpx;
		display: flex;
		align-items: center;
		filter: grayscale(100%);
		-webkit-filter: grayscale(100%);
		-moz-filter: grayscale(100%);
		-ms-filter: grayscale(100%);
		-o-filter: grayscale(100%);
		filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
		-webkit-filter: grayscale(1);
	}
</style>
